package com.xzcedu.transformation;

import java.io.*;

/**
 * @author 徐州城
 * @version 1.0
 * 演示 OutputStreamWriter 使用
 * 把FileOutputStream 字节流，转成字符流
 * 指定处理的编码，gbk/utf-8/utf8
 */
public class OutputStreamWriter_ {
    public static void main(String[] args) throws IOException {

        String filePath = "e:\\f1.txt";
        String charSet = "UTF-16";

        OutputStreamWriter osw = new OutputStreamWriter(new FileOutputStream(filePath), charSet);//指定编码

        osw.write("Reading this book");

        osw.close();
//        BufferedWriter bw = new BufferedWriter(osw);
//
//        bw.write("This is book");
//
//        bw.close();

        System.out.println("按照" + charSet + "保存编码");

    }
}
